Public Class FormProgessBar

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(3)
        If ProgressBar1.Value = 100 Then
            'Check database connection
            Dim cn = Dbinterface.Connection
            If cn.State = ConnectionState.Closed Then
                Label2.Text = "Error Database loading ..."
                lblTryAgain.ForeColor = Color.Red
                lblTryAgain.Show()
                Exit Sub
            Else
                Me.Hide()
                Timer1.Stop()

                FormMain.Show()
            End If


        End If

        Label1.Text = ProgressBar1.Value & (" %")
    End Sub

    Private Sub FormProgessBar_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lblTryAgain.Hide()
        Label1.ForeColor = Color.Gray
        Label2.ForeColor = Color.Gray
        ProgressBar1.Hide()
        Timer1.Start()
    End Sub

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        Dbinterface.OpenConnection()
        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub Label3_Click(sender As Object, e As EventArgs) Handles lblTryAgain.Click
        Application.Restart()
    End Sub
End Class